import math

dir='/media/a75874b2-4e13-46dc-a842-034a9ba570f9/resultados/MagneticGel/eps5.0/u20/FREQ/'
dir='/media/a75874b2-4e13-46dc-a842-034a9ba570f9/resultados/MagneticGel/eps5.0/u20/FREQ/'
dir='/media/a75874b2-4e13-46dc-a842-034a9ba570f9/resultados/MagneticGel/eps10.0/FREQ/G2.5/'
dir='/home/jcfernandez/resultados/eps1/u100/AMPL/W2.0/'
name='sigmadelta.dat'
amplitud=True
frecuencia=False

datos=[]
for line in file(dir+name):
    line=line.replace('\n','')
    val=line.split('\t')
    if len(val)==1:
        val=line.split(' ')
    res=[]
    for v in val:
        if v!='':
            res.append(float(v))
    datos.append(res)

if frecuencia:
    gamma0=0.025
    #f = open(dir+"G1G2Gamm0.025FREQ.dat","w")
    f = open(dir+"G1G2E10U0A2.5Freq.dat","w")
    for dt in datos:
        G1=dt[1]*math.cos(dt[2])/gamma0
        G2=dt[1]*math.sin(dt[2])/gamma0
        f.write(str(dt[0])+' '+str(G1)+' '+str(G2)+' '+str(dt[1])+' '+str(dt[2])+'\n')
        print "G': ",G1, "G'': ",G2
    f.close()

if amplitud:
    #f = open(dir+"G1G2Gamm0.025FREQ.dat","w")
    f = open(dir+"G1G2Eps10U0W10Ampl.dat","w")
    for dt in datos:
        G1=100.0*dt[1]*math.cos(dt[2])/dt[0]
        G2=100.0*dt[1]*math.sin(dt[2])/dt[0]
        f.write(str(0.1*dt[0])+' '+str(G1)+' '+str(G2)+' '+str(dt[1])+' '+str(dt[2])+'\n')
        print "G': ",G1, "G'': ",G2
    f.close()
